import request from '@/utils/request'
import request2 from '@/utils/request2'

import { Row } from 'element-ui'

export function updateMoveDocument(data) {
  return request({
    url: '/api/fd/document/update_move',
    method: 'post',
    data
  })
}

export function updateDocument(data) {
  return request({
    url: '/api/fd/document/update',
    method: 'post',
    data
  })
}

export function deleteDocument(data) {
  return request({
    url: '/api/fd/document/delete',
    method: 'post',
    data
  })
}

export function recoverDocument(data) {
  return request({
    url: '/api/fd/document/recover',
    method: 'post',
    data
  })
}
/**
 * 新建
 * @param data
 * @returns {AxiosPromise}
 */

export function createDocument(data) {
  return request({
    url: '/api/fd/document/create',
    method: 'post',
    data
  })
}
/**
 * 上传
 * @param data
 * @returns {AxiosPromise}
 */

export function uploadDocument(data) {
  return request({
    url: '/api/fd/document/upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data;charset=utf-8'
    }
  })
}

/**
 * 获取文档信息
 * @param data
 * @returns {AxiosPromise}
 */
export function getDocumentInfo(data) {
  return request({
    url: '/api/fd/document/getDocumentInfo',
    method: 'post',
    data
  })
}

/**
 * 获取文档配置信息-用于onlyOffice config信息获取
 * @param data
 * @returns {AxiosPromise}
 */
export function getDocument(data) {
  return request({
    url: '/api/fd/document/getDocument',
    method: 'post',
    data
  })
}

/**
 * 用于文档选择时候的复制
 * @param data
 * @returns {AxiosPromise}
 */
export function copy(data) {
  return request2({
    url: '/api/fd/document/copy',
    method: 'post',
    data
  })
}

/**
 * 获取我的分享列表
 * @param data
 * @returns {AxiosPromise}
 */
export function getshareltis(data) {
  return request({
    url: '/api/fd/document_share/get',
    method: 'post',
    data
  })
}

/**
 * 分享
 * @param data
 * @returns {AxiosPromise}
 */
export function saveshare(data) {
  return request({
    url: '/api/fd/document_share/save',
    method: 'post',
    data
  })
}

/**
 * 文档关联新增接口
 * @param data
 * @returns {AxiosPromise}
 */
export function saveRelation(data) {
  return request({
    url: '/api/fd/document_relation/save',
    method: 'post',
    data
  })
}

/**
 * 文档关联数据查新接口
 * @param data
 * @returns {AxiosPromise}
 */
export function pageRelation(data) {
  return request({
    url: '/api/fd/document_relation/page',
    method: 'post',
    data
  })
}

/**
 * 根据文件名模糊查询文件
 * @param data
 * @returns {AxiosPromise}
 */

export function fuzzySearchDocument(data) {
  return request({
    url: '/api/fd/document/fuzzySearchDocument',
    method: 'post',
    data
  })
}

/**
 * 批量删除
 * @param data
 * @returns {AxiosPromise}
 */

export function deleteByIds(data) {
  return request({
    url: '/api/fd/document/delete_by_ids',
    method: 'post',
    data
  })
}

/**
 * 批量恢复
 * @param data
 * @returns {AxiosPromise}
 */

export function recoverByIds(data) {
  return request({
    url: '/api/fd/document/recover_by_ids',
    method: 'post',
    data
  })
}

/**
 * 获取文件编码
 * @param data
 * @returns {AxiosPromise}
 */

export function generateCode(data) {
  return request({
    url: '/api/fd/document_code/generate_code',
    method: 'post',
    data
  })
}

/**
 * 永久删除文件和文件夹
 * @param data
 * @returns {AxiosPromise}
 */
export function realDelete(data) {
  return request({
    url: '/api/fd/document/real_delete',
    method: 'post',
    data
  })
}
/**
 * 通过文件编号获取文件
 * @param data
 * @returns {AxiosPromise}
 */

export function getDocumentByCode(data) {
  return request({
    url: '/api/fd/document_code/get_document_by_code',
    method: 'post',
    data
  })
}

/**
 * 文件下载
 * @param data
 * @returns {AxiosPromise}
 */

export function downloadFile(data) {
  return request({
    url: '/api/fd/document/download_file',
    method: 'post',
    data
  })
}

/**
 * 根据文档Id获取文档操作记录
 * @param data
 * @returns {AxiosPromise}
 */

export function listData(data) {
  return request({
    url: '/api/fd/document_log/list',
    method: 'post',
    data
  })
}

/**
 * 取消关联
 * @param data
 * @returns {AxiosPromise}
 */

export function deleteRelevance(data) {
  return request({
    url: '/api/fd/document_relation/delete',
    method: 'post',
    data
  })
}

/**
 * 处理收藏文件已删除
 * @param data
 * @returns {AxiosPromise}
 */
export function favoriteDelete(data) {
  return request({
    url: '/api/fd/document_favorite/delete',
    method: 'post',
    data
  })
}

/**
 * 处理分享文件已删除
 * @param data
 * @returns {AxiosPromise}
 */
export function relDelete(data) {
  return request({
    url: '/api/fd/document_share/rel_delete',
    method: 'post',
    data
  })
}

/**
 * 处理最近操作文件已删除
 * @param data
 * @returns {AxiosPromise}
 */
export function historyDelete(data) {
  return request({
    url: '/api/fd/document_history/delete',
    method: 'post',
    data
  })
}

/**
 * 现行文件的常用记录
 * @param data
 * @returns {AxiosPromise}
 */
export function releaseOftenUse(data) {
  return request({
    url: '/api/fd/document_release_often_use/increment',
    method: 'post',
    data
  })
}

/**
 * 查询文件包集合
 * @param data
 * @returns {AxiosPromise}
 */
export function backDocumentListByIds(data) {
  return request({
    url: '/api/fd/document/list_by_ids',
    method: 'post',
    data
  })
}

/**
 * 获取流程字典信息
 * @param data
 * @returns {AxiosPromise}
 */
export function flowListPreOptions() {
  return request({
    url: '/api/xd/document_flow/list_pre_options',
    method: 'get'
  })
}

/**
 * 查询文件编号是否重复
 * @param data
 * @returns {AxiosPromise}
 */
export function getDocumentCodeIsExisted(data) {
  return request({
    url: '/api/fd/document_code/get_document_code_is_existed',
    method: 'post',
    data
  })
}